(function () {
    'use strict';
    angular
        .module('logcenterApp')
        .service('AlertUserService',AlertUserService);

    AlertUserService.$inject=['$http','$q'];
    function AlertUserService($http,$q) {
        var query=function (condition) {
            var deferred=$q.defer();
            $http.post('api/log-alert/alert-user/query',condition).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };

        var save=function (entity) {
            var deferred=$q.defer();
            $http.post('api/log-alert/alert-user/save',entity).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        var destroy=function (entity) {
            var deferred=$q.defer();
            /*$http({
                url:'/api/log-alert/alert-sub/delete',
                method:'DELETE',
                data:entity
            }).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });*/
            //return deferred.promise;
            $http.post('api/log-alert/alert-user/delete',entity).then(function (resp) {
                deferred.resolve(resp.data);
            },function (error) {
                deferred.reject(error);
            });
            return deferred.promise;
        };
        return{
            query:query,
            save:save,
            destroy:destroy
        };
    }
})();
